#ifndef VENUS_RAY_MARCHING_FLUID_SYSTEM_H
#define VENUS_RAY_MARCHING_FLUID_SYSTEM_H

#include "graphics/program_cg.h"
#include "volume_buffer.h"

namespace venus {
class FluidSystem {
public:
  FluidSystem(CGcontext context, int width, int height, int depth);
  ~FluidSystem();
  void Reset();
  void Step(float timestep);
  void Splat();
  VolumeBuffer *GetStateBuffer() { return states_[current_state_idx_]; }
private:
  float frand();
  int width_, height_, depth_;

  VolumeBuffer *states_[2];
  VolumeBuffer *prev_state_;
  int current_state_idx_;

  CGcontext cg_context_;
  ProgramCG *clear_prog_, *copy_prog_, *splat_prog_;
  ProgramCG *step_prog_;
  CGparameter voxel_size_;
  CGparameter damping_;
  CGparameter centre_, radius_;
  CGparameter splat_color_;
  CGparameter clear_color_;
  CGparameter tex_, prev_tex_, current_tex_;
  int tex_unit_, prev_tex_unit_, current_tex_unit_;
};
} // namespace venus

#endif // VENUS_RAY_MARCHING_FLUID_SYSTEM_H
